상태바 컴포넌트 개발#23
Conversation
Summary of ChangesHello @HWAN0218, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 애플리케이션 내에서 진행 상태를 명확하게 시각화하기 위한 새로운 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
상태바 컴포넌트 추가에 대한 PR을 검토했습니다. 전반적으로 잘 작성되었지만, 몇 가지 개선점을 제안합니다. CSS에서 repeating-linear-gradient 구문 오류가 있어 의도한 배경이 렌더링되지 않는 버그를 수정해야 합니다. 또한, 특정 조건에서 컴포넌트가 처음 렌더링될 때 깜빡이는 현상이 발생할 수 있는 로직을 수정했습니다. 마지막으로, useEffect의 복잡도를 낮추기 위한 리팩토링을 제안했습니다. 자세한 내용은 각 주석을 확인해주세요.
| repeating-linear-gradient( | ||
| -45deg, | ||
| rgba(0, 0, 0, 0.04) 0px, | ||
| rgba(0, 0, 0, 0.04) 40px, | ||
| rgba(255, 255, 255, 0.7) 10px, | ||
| rgba(255, 255, 255, 0.7) 80px | ||
| ), |
There was a problem hiding this comment.
repeating-linear-gradient의 color-stop 순서가 올바르지 않아 그래디언트가 렌더링되지 않는 버그가 있습니다. color-stop의 위치 값은 오름차순으로 정렬되어야 합니다. 현재 코드에서는 40px 다음에 10px가 나와서 유효하지 않은 구문입니다.
의도하신 디자인이 줄무늬 패턴이라고 추측하여 아래와 같이 수정하는 것을 제안합니다. 이 코드는 40px 너비의 어두운 줄과 40px 너비의 밝은 줄이 반복되는 패턴을 만듭니다.
| repeating-linear-gradient( | |
| -45deg, | |
| rgba(0, 0, 0, 0.04) 0px, | |
| rgba(0, 0, 0, 0.04) 40px, | |
| rgba(255, 255, 255, 0.7) 10px, | |
| rgba(255, 255, 255, 0.7) 80px | |
| ), | |
| repeating-linear-gradient( | |
| -45deg, | |
| rgba(0, 0, 0, 0.04) 0px, | |
| rgba(0, 0, 0, 0.04) 40px, | |
| rgba(255, 255, 255, 0.7) 40px, | |
| rgba(255, 255, 255, 0.7) 80px | |
| ), |
| useEffect(() => { | ||
| const el = fillRef.current; | ||
| if (!el) return; | ||
|
|
||
|
|
||
| el.style.setProperty('--pb-duration', animate ? `${durationMs}ms` : '0ms'); | ||
|
|
||
|
|
||
| if (!animate) { | ||
| el.style.width = `${targetPercent}%`; | ||
| didMountRef.current = true; | ||
| return; | ||
| } | ||
|
|
||
| const isFirstMount = !didMountRef.current; | ||
| didMountRef.current = true; | ||
|
|
||
|
|
||
| if (replayOnMount && isFirstMount) { | ||
| el.style.width = '0%'; | ||
|
|
||
| if (rafRef.current !== null) cancelAnimationFrame(rafRef.current); | ||
| rafRef.current = requestAnimationFrame(() => { | ||
| el.style.width = `${targetPercent}%`; | ||
| }); | ||
|
|
||
| return () => { | ||
| if (rafRef.current !== null) cancelAnimationFrame(rafRef.current); | ||
| }; | ||
| } | ||
|
|
||
| // 값 변경 시 자연스럽게 이동 | ||
| el.style.width = `${targetPercent}%`; | ||
| }, [animate, durationMs, replayOnMount, targetPercent]); |
There was a problem hiding this comment.
현재 useEffect 훅은 애니메이션 지속 시간 설정, 애니메이션 비활성화 처리, 첫 마운트 시 애니메이션 재생 등 여러 책임을 가지고 있어 복잡성이 높습니다.
코드를 더 읽기 쉽고 유지보수하기 좋게 만들기 위해 이 useEffect를 여러 개의 작은 훅으로 분리하거나, 관련 로직을 useProgressAnimation과 같은 커스텀 훅으로 추출하는 것을 고려해 보세요.
예를 들어, --pb-duration CSS 변수를 설정하는 로직과 너비(width)를 업데이트하는 로직을 별도의 useEffect로 분리할 수 있습니다.
// 예시
useEffect(() => {
const el = fillRef.current;
if (!el) return;
el.style.setProperty('--pb-duration', animate ? `${durationMs}ms` : '0ms');
}, [animate, durationMs]);
useEffect(() => {
const el = fillRef.current;
if (!el) return;
// 너비 업데이트 및 애니메이션 로직
// ...
}, [animate, replayOnMount, targetPercent]);| <div | ||
| ref={fillRef} | ||
| className={styles.fill} | ||
| style={{ width: replayOnMount ? '0%' : `${targetPercent}%` }} |
There was a problem hiding this comment.
animate prop이 false이고 replayOnMount가 true일 때, 프로그레스 바의 초기 너비가 0%로 설정되었다가 useEffect에 의해 즉시 targetPercent%로 변경됩니다. 이로 인해 원치 않는 깜빡임(flash)이 발생할 수 있습니다.
animate가 false일 때는 replayOnMount 설정과 관계없이 항상 targetPercent%로 초기화되어야 합니다.
아래와 같이 수정하여 애니메이션이 활성화된 경우에만 replayOnMount 로직이 초기 너비에 영향을 주도록 하는 것을 제안합니다.
| style={{ width: replayOnMount ? '0%' : `${targetPercent}%` }} | |
| style={{ width: animate && replayOnMount ? '0%' : `${targetPercent}%` }} |
Summary
Issue
Scope
포함
특이사항
없음